package io.github.jesse205.deskclock.lite.utils;

public class DynamicSizeHelper {
    private float textSizeWidthFactor = 0;
    private float textSizeHeightFactor = 0;

    public void setTextSizeWidthFactor(float factor) {
        textSizeWidthFactor = factor;
    }

    public float getTextSizeWidthFactor() {
        return textSizeWidthFactor;
    }

    public void setTextSizeHeightFactor(float factor) {
        textSizeHeightFactor = factor;
    }

    public float getTextSizeHeightFactor() {
        return textSizeHeightFactor;
    }

    public float calculateTextSize(int width, int height) {
        if (width > 0 && textSizeWidthFactor > 0 && height > 0 && textSizeHeightFactor > 0) {
            return Math.min(width * textSizeWidthFactor, height * textSizeHeightFactor);
        } else if (width > 0 && textSizeWidthFactor > 0) {
            return width * textSizeWidthFactor;
        } else if (height > 0 && textSizeHeightFactor > 0) {
            return height * textSizeHeightFactor;
        } else {
            return 0;
        }
    }
}
